// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/parking/api/ParkRecordApi'

import ComClass from '@api/ComQuery'
import ListClass from '@api/parking/model/ParkRecordListQueryReq'

const CLIENT = CORE.grpcCLIENT(Client)
const COM = [ComClass, 'comQuery']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  validParam(param, state, root) {
    return root.state.one.id
  },
  transParam(param, { rootState: { one: { id } } }) {
    return { ...param, entranceId: id }
  },
  async getList(param, TIP = '查询通行记录') {
    const DTO = CORE.grpcDTO(ListClass, param, COM)
    const resp = await CORE.grpc(TIP, CLIENT, 'queryParkRecordList', DTO)
    return [resp.comQuery.totalCount, resp.parkRecordDto || []]
  },
}
